package com.iona.json.builders;

import java.util.List;

import com.iona.domain.StagesOfFormation;
import com.iona.json.JSONArray;
import com.iona.json.JSONBuilder;
import com.iona.json.JSONException;

public class StagesOfFormationBuilder extends JSONBuilder {

	private final List<StagesOfFormation> stageOfFormation;

	public StagesOfFormationBuilder(List<StagesOfFormation> findAll) {
		this.stageOfFormation = findAll;
	}

	@Override
	public Object build() throws JSONException {
		JSONArray root = new JSONArray();
		for (StagesOfFormation sof : stageOfFormation) {
			JSONArray arr = new JSONArray();
			arr.put(sof.getId());
			arr.put(sof.getName());
			root.put(arr);
		}
		return root;
	}

	@Override
	public String name() {
		return getClass().getSimpleName();
	}

}
